package com.atguigu.flinksql.daytest.fun;

import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

/**
 * ClassName: userUDTF
 * Package: com.atguigu.flinksql.daytest.fun
 * Description:
 *
 *                  str形如:"hello-world_hello-atguigu"
 *  	        	====>
 *  	        		a列    b列
 *  	        		hello,world
 *  	        		hello,atguigu
 * @Author ChenJun
 * @Create 2023/4/22 8:47
 * @Version 1.0
 */
@FunctionHint(output = @DataTypeHint("ROW<word1 STRING, word2 string>"))
public class userUDTF extends TableFunction<Row> {

    public void eval(String str) {
        for (String s : str.split("_")) {
            String[] split = s.split("-");
            collect(Row.of(split[0], split[1]));
        }
    }


}
